﻿package mortal.game.view.forging.renderer
{
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.forging.*;
    import mortal.game.view.forging.view.*;
    import mortal.game.view.palyer.*;

    public class PackGemItemCellRenderer extends GCellRenderer
    {
        private var _item:BaseItem;

        public function PackGemItemCellRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.mouseEnabled = true;
            this._item = UICompomentPool.getUICompoment(BaseItem);
            this._item.setItemStyle(ItemStyleConst.Small);
            this._item.mouseEnabled = true;
            this.addChild(this._item);
            this._item.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            if (param1 is ItemData)
            {
                this._item.itemData = param1 as ItemData;
            }
            else
            {
                this._item.itemData = null;
            }
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            var _loc_3:GemInfo = null;
            if (this._item.itemData == null)
            {
                return;
            }
            var _loc_2:* = (GameController.forging.view as ForgingModule).equipDisplaySpr.currSelEquip;
            if (_loc_2 && _loc_2.itemData)
            {
                _loc_3 = GemStrengthenPanelNew.currSelGem;
                if (_loc_3 && _loc_3.data)
                {
                    GameProxy.equip.jewelEmbedNew(_loc_2.itemData.uid, _loc_3.index, this._item.itemData.uid);
                    GemSelWin.instance.hide();
                }
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._item.dispose();
            this._item = null;
            return;
        }// end function

    }
}
